<?php


namespace Xy\Rbac\Controllers;


use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Xy\Rbac\Services\RbacPowerPageService;

class RbacPowerPageController extends Controller {
    public $exceptActionList = ['userPermission'];
    
    protected $_rbacPowerPageService;
    
    public function __construct(RbacPowerPageService $rbacPowerPageService) {
        $this->_rbacPowerPageService = $rbacPowerPageService;
    }
    
    /**
     * @return array
     */
    public function index() {
        return $this->_rbacPowerPageService->getRabcPowerPage();
    }
    
    /**
     * @param Request $request
     *
     * @return mixed
     */
    public function store(Request $request) {
        return $this->_rbacPowerPageService->storeRabcPowerPage($request);
    }
    
    /**
     * @param $id
     *
     * @return array
     * @throws \Exception
     */
    public function destroy($id) {
        return $this->_rbacPowerPageService->destroyRabcPowerPage($id);
    }
    
    /**
     * @param Request $request
     * @param         $id
     *
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
     * @throws \Exception
     */
    public function update(Request $request, $id) {
        return $this->_rbacPowerPageService->updateRabcPowerPage($id, $request);
    }
    
    /**
     * @return array
     */
    public function userPermission() {
        return $this->_rbacPowerPageService->getUserPermission();
    }
}